package com.ruoyi.task;

import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.PersistJobDataAfterExecution;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author alison
 * @Date 2024/11/27 14:28
 * @Version 1.0
 * @Description
 */
@PersistJobDataAfterExecution// 有状态的job
@DisallowConcurrentExecution // 禁止并发访问
public class A2_DefaultJob implements Job {
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        if (context == null) {
            return;
        }
        System.out.println("now: " + LocalDateTime.now());
        System.out.println("now-jobkey-name: " + context.getJobDetail().getKey().getName());
        System.out.println("jobKey: " + context.getJobDetail().getKey().toString());
        System.out.println("TriggerKey: " + context.getTrigger().getKey().toString());
    }
}
